﻿#include "login.h"
#include "ui_login.h"
#include <QSqlQuery>
#include <QDebug>
#include <QMessageBox>
#pragma execution_character_set("utf-8")


Login::Login(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::Login)
{
    ui->setupUi(this);
}

Login::~Login()
{
    delete ui;
}

void Login::on_pB_cancle_clicked()
{
    exit(0);
}

void Login::on_pB_login_clicked()
{

    QString username = ui->lE_username->text();
    QString password = ui->lE_password->text();

    // 判断用户名与密码非空
    if(username=="" || password == "")
    {
        QMessageBox::information(this,"提示","用户名或密码不能为空");
    }else
    {


        QSqlQuery query;
        bool i = query.exec(QString("SELECT * FROM login WHERE NAME = '%1'").arg(username));
        qDebug() << "iiiiiiiiiii: " << i;
        while (query.next())
        {
            qDebug() << "111111111111";
            if(query.value("PASSWORD").toString() == password)
            {

            }
            else
            {
                 QMessageBox::information(this,"提示","用户名或密码错误");
            }
        }
    }
    // 判断用户名与密码是否正确
    /* QSqlQuery query;
    query.exec(QString("SELECT * FROM login WHERE Pl_ygbh = '%1'").arg(Pl_ygbh));
    while(query.next())
    {

    }*/

}
